#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int arr1[n];
    int arr2[m];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &arr2[i]);
    }
    int i = 0;
    int j = 0;
    while (i < n || j < m)
    {
        if (arr1[i] <= arr2[j] && i < n)
        {
            printf("%d ", arr1[i]);
            i++;
        }
        else if (arr1[i] > arr2[j] && j < m)
        {
            printf("%d ", arr2[j]);
            j++;
        }
        else if (i >= n && j < m)
        {
            printf("%d ", arr2[j]);
            j++;
        }
        else if (i < n && j >= m)
        {
            printf("%d ", arr1[i]);
            i++;
        }
    }
    return 0;
}